<?php $_option = $this->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default     = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>
<?php $tierPriceHtml = ''; ?>

<dt>
    <label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->escapeHtml($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label>
</dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    <div class="input-box">
        <?php /** @var $_selection Mage_Catalog_Model_Product*/ ?>
        <?php if ($this->_showSingle()): ?>
            <?php echo $this->getSelectionTitlePrice($_selections[0]); ?>
            <?php if ($_selections[0]->getSelectionCanChangeQty()): ?>
                <?php $tierPriceHtml = $this->getTierPriceHtml($_selections[0]); ?>
        <?php endif; ?>
        <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>" />
    <?php else:?>
        <ul class="options-list">
        <?php if (!$_option->getRequired()): ?>
            <li><input type="radio" onclick="bundle.changeSelection(this)" class="radio bundle-radio" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]"<?php echo ($_default && $_default->isSalable())?'':' checked="checked" ' ?> value=""/>
            <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>"><?php echo $this->__('None') ?></label></span>
            </li>
        <?php endif; ?>
        <?php foreach ($_selections as $_selection): 
			$qty_stock = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_selection)->getQty();
			if ($this->_isSelected($_selection)) { $item_selected = $_selection->getSelectionId(); }
		?>
            <?php if ($_selection->getSelectionCanChangeQty() && $this->_isSelected($_selection)): ?>
                <?php $tierPriceHtml = $this->getTierPriceHtml($_selection); ?>
            <?php endif; ?>
            <li><input type="radio" onclick="bundle.changeSelection(this)" class="bundle-radio radio<?php echo $_option->getRequired()?' validate-one-required-by-name':'' ?> change-container-classname" id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]"<?php if ($this->_isSelected($_selection)) echo ' checked="checked"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>value="<?php echo $_selection->getSelectionId() ?>"/>
            <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"><?php echo $this->getSelectionTitlePrice($_selection) ?></label></span>
            <?php if ($_option->getRequired()): ?>
                <?php echo $this->setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?>
            <?php endif; ?>
				<input type="hidden" id="minQty_<?php echo $_selection->getSelectionId(); ?>" name="minQty" value="<?php echo $_selection->getStockItem()->getMinSaleQty(); ?>"/>
				<input type="hidden" id="maxQty_<?php echo $_selection->getSelectionId(); ?>" name="maxQty" value="<?php echo $_selection->getStockItem()->getMaxSaleQty(); ?>"/>
				<input type="hidden" id="qtyStock_<?php echo $_selection->getSelectionId(); ?>" name="qtyStock" value="<?php echo $qty_stock; ?>"/>
				<input type="hidden" id="qty_default<?php echo $_selection->getSelectionId(); ?>" name="qty_default" value="<?php echo $_selection->getSelectionQty(); ?>"/>
				<input type="hidden" id="proName<?php echo $_selection->getSelectionId(); ?>" name="proName" value="<?php echo $_selection->getName(); ?>"/>
			</li>
        <?php endforeach; ?>
        </ul>
		<input type="hidden" id="item-selected-radio-<?php echo $_option->getId() ?>" class="item-selected" name="item-selected" value="<?php if(isset($item_selected)){ echo $item_selected;} ?>"/>
        <div id="bundle-option-<?php echo $_option->getId() ?>-container"></div>
    <?php endif; ?>
    </div>
    <span id="bundle-option-<?php echo $_option->getId() ?>-tier-prices"> <?php echo $tierPriceHtml; ?></span>
    <span class="qty-holder">
        <label for="bundle-option-<?php echo $_option->getId() ?>-qty-input"><?php echo $this->__('Qty:') ?> </label><input onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>"/>
    </span>
</dd>